package com.sulink.numberkeyboard.popWindow;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sulink.numberkeyboard.R;


/**
 * 适用于综合支付
 * <p>
 * 需要显示哪一项就设置对应项的值
 */
public class SimplePayPopWindow extends BasePayPop implements View.OnClickListener {


    private ImageView mIvDelete; //删除图标
    private TextView mTvPayValue; //支付金额
    private TextView mTvAmount; //总金额
    private TextView mTvDeduction;//抵扣
    private TextView mTvPayType;//支付币种类型
    private ImageView mIvPayType;//支付币种图标
    private TextView mTvBalance;//余额


    public SimplePayPopWindow(Context context) {
        super(context);
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.pop_simple_pay_layout;
    }


    @Override
    protected void initView(View view) {
        super.initView(view);

        mIvDelete = view.findViewById(R.id.iv_delete);
        mIvDelete.setOnClickListener(this);

        mTvPayValue = view.findViewById(R.id.tv_payValue);
        mIvPayType = view.findViewById(R.id.iv_payType);
        mTvAmount = view.findViewById(R.id.tv_amount);
        mTvDeduction = view.findViewById(R.id.tv_deduction);
        mTvPayType = view.findViewById(R.id.tv_payType);
        mTvBalance = view.findViewById(R.id.tv_balance);

    }


    @Override
    public void onClick(View v) {
        dismiss();
    }


    /**
     * 设置显示的支付金额
     *
     * @param value
     */
    public void setTvPayValue(String value) {
        mTvPayValue.setText(value);
    }


    /**
     * 设置币种图标url
     *
     * @param url
     */
    public void setPayTypeImageUrl(String url) {
        mIvPayType.setVisibility(View.VISIBLE);
        Glide.with(mContext).load(url).into(mIvPayType);
    }

    /**
     * 设置币种图标资源Id
     *
     * @param resId
     */
    public void setPayTypeImageResource(int resId) {
        mIvPayType.setVisibility(View.VISIBLE);
        Glide.with(mContext).load(resId).into(mIvPayType);
    }

    /**
     * 设置币种单位
     *
     * @param unit
     */
    public void setTvPayType(String unit) {
        mTvPayType.setVisibility(View.VISIBLE);
        mTvPayType.setText(unit);
    }

    /**
     * 设置显示的余额
     *
     * @param balance
     */
    public void setTvBalance(String balance) {
        mTvPayType.setVisibility(View.VISIBLE);
        mTvBalance.setVisibility(View.VISIBLE);
        mTvBalance.setText(mContext.getString(R.string.numberKeyboard_balance, balance));
    }

    /**
     * 设置抵扣显示
     *
     * @param deduction
     */
    public void setTvDeduction(String deduction) {
        mTvDeduction.setVisibility(View.VISIBLE);
        mTvDeduction.setText(deduction);
    }


    /**
     * 显示总金额
     *
     * @param amount
     */
    public void setTvAmount(String amount) {
        mTvAmount.setVisibility(View.VISIBLE);
        mTvAmount.setText(amount);
        mTvAmount.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    }
}
